#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
vector<int>x,y,vx,vy;
//int h[2000005];
int ans=0;
void func(vector<int>&x,vector<int>&vx)
{
    for(int i=1;i<=n;i++)
    {
        unordered_map<int, int>h;
        int cnt=1;
        for(int j=1;j<=n;j++)
        {
            if(i==j)continue;
            if(vx[i]==vx[j])
            {
                if(x[i]==x[j])cnt++;
                if(ans<cnt)ans=cnt;
                continue;
            }
            int dx=x[i]-x[j];
            int dv=vx[j]-vx[i];
            int t=dx/dv;
            if(dx%dv||t<0)continue;
            h[t]++;
            if(ans<h[t]+cnt)ans=h[t]+cnt;
        }
    }
}
void solve()
{
    cin>>n;
    x=y=vx=vy=vector<int>(n+1);
    for(int i=1;i<=n;i++)
    {
        int v;
        char d;
        cin>>x[i]>>y[i]>>v>>d;
        if(d=='R')vx[i]=v;
        if(d=='L')vx[i]=-v;
        if(d=='U')vy[i]=v;
        if(d=='D')vy[i]=-v;
    }
    func(x,vx);
    func(y,vy);
    cout<<ans;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}